package com.XinYun.Library.modules.show.controller;

import com.XinYun.Library.modules.display.entity.book;

import java.io.IOException;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import com.XinYun.Library.modules.show.dao.sql;
import com.XinYun.Library.modules.show.entity.bookcontent;

public class showImpl implements show{

    @Override
    public List<bookcontent> get(String value) throws SQLException, IOException {
        String sql1="select intro,`like` from books_info where bookname=?;";
        String sql2="select content from book_comment where bookname=?;";
        //执行方法
        ResultSet resultSet1=sql.select1(sql1,value);
        ResultSet resultSet2=sql.select2(sql2,value);
        //将结果传入集合
        List<bookcontent> bookcontentsList=new ArrayList<>();
        bookcontent bookcontent=null;
        while(resultSet1.next()&&resultSet2.next()){
            bookcontent=new bookcontent();
            bookcontent.setIntroduce(resultSet1.getString("intro"));
            bookcontent.setLike(resultSet1.getInt("like"));
            bookcontent.setComment(resultSet2.getString("content"));
            bookcontentsList.add(bookcontent);
        }
        return bookcontentsList;
    }
}
